package com.kaili;

import com.kaili.common.aop.SpringContextHolder;
import com.kaili.common.config.druid.WebMvcConfig;
import com.kaili.common.response.ResponseBodyWrapFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

//@EnableResourceServer
@EnableDiscoveryClient
@SpringBootApplication
//开启断路器功能
@EnableCircuitBreaker
@EnableFeignClients
@MapperScan("com.kaili.db.mapper")
@ComponentScan(basePackages={"com.kaili"},excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,value=WebMvcConfig.class),@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,value=SpringContextHolder.class)})
@EnableTransactionManagement(proxyTargetClass = true)
@EnableSwagger2
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 18000)
public class Operation {
	public static void main(String[] args) {
		new SpringApplicationBuilder(Operation.class).web(true).run(args);
		System.out.println("***************************************************************************************");
		System.out.println("***************************************************************************************");
		System.out.println("****重要说明:controller下对数据库读操作的必须以下列前缀开头:select,get,query,search****");
		System.out.println("***************************************************************************************");
		System.out.println("***************************************************************************************");
	}

	/**
	 * 返回值包装
	 */
	@Bean
	public ResponseBodyWrapFactoryBean getResponseBodyWrap() {
		return new ResponseBodyWrapFactoryBean();
	}
}
